package com.daxt.model.service.archives.vo;

import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import lombok.Generated;
import org.springframework.format.annotation.DateTimeFormat;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.daxt.model.service.archives.base.ArchivesListBase;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "档案案件基础列", description = "档案案件基础列")
//@Document(indexName = "archivesDoc",type = "_doc", shards = 1, replicas = 0)
//@TableName("\"daxt\".\"ARCHIVES_DOC\"")
@TableName("archives_doc")
public class ArchivesDoc extends ArchivesListBase implements Serializable {

    /**
     *
     */
    private static final long serialVersionUID = 1L;


    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @ApiModelProperty(value = "卷ID", name = "dossierId")
    private Long dossierId;

    @ApiModelProperty(value = "档号", name = "archivalNum")
    private String archivalNum;

    @ApiModelProperty(value = "全宗id", name = "fondsId")
    private String fondsId;

    @TableField(exist = false)
    @ApiModelProperty(value = "全宗号", name = "fondsNum")
    private String fondsNum;

    @TableField(exist = false)
    @ApiModelProperty(value = "全宗名", name = "fondsName")
    private String fondsName;

    @ApiModelProperty(value = "门类Id", name = "typeId")
    private Long typeId;

    @TableField(exist = false)
    @ApiModelProperty(value = "门类号", name = "typeNum")
    private String typeNum;

    @TableField(exist = false)
    @ApiModelProperty(value = "门类名称", name = "typeName")
    private String typeName;

    @ApiModelProperty(value = "分类ID", name = "classId")
    private Long classId;

    @TableField(exist = false)
    @ApiModelProperty(value = "分类号", name = "classNum")
    private String classNum;

    @TableField(exist = false)
    @ApiModelProperty(value = "分类名称", name = "className")
    private String className;

    @TableField(exist = false)
    @ApiModelProperty(value = "父分类名称", name = "parentClassName")
    private String parentClassName;
    /*@TableField(exist = false)
    @ApiModelProperty(value = "质保资料合同段名", name = "zbHeTongName")
    private String zbHeTongName;
    @TableField(exist = false)
    @ApiModelProperty(value = "质保资料单位工程名", name = "zbDeptName")
    private String zbDeptName;*/

    @TableField(exist = false)
    @ApiModelProperty(value = "分类树号", name = "classTreeStr")
    private String classTreeStr;

    @ApiModelProperty(value = "卷号", name = "dossierNum")
    private String dossierNum;

    @ApiModelProperty(value = "件号", name = "itemNum")
    private String itemNum;

    @ApiModelProperty(value = "件数", name = "itemCount")
    private String itemCount;

    @ApiModelProperty(value = "页号", name = "pageNum")
    private String pageNum;

    @ApiModelProperty(value = "类目号", name = "categoryNum")
    private String categoryNum;

    @ApiModelProperty(value = "年度", name = "archivalYear")
    private String archivalYear;

    @ApiModelProperty(value = "保管期限", name = "storagePeriod")
    private String storagePeriod;

    //@ApiModelProperty(value = "日期", name = "archivesDate")
//	private String archivesDate;

    @ApiModelProperty(value = "案件题名", name = "title")
    private String title;

    @ApiModelProperty(value = "页数", name = "pages")
    private String pages;

    @ApiModelProperty(value = "责任单位", name = "dutyCompany")
    private String dutyCompany;

    @ApiModelProperty(value = "责任人", name = "dutyPeople")
    private String dutyPeople;

    @ApiModelProperty(value = "密级", name = "secret")
    private String secret;

    @ApiModelProperty(value = "备注", name = "remark")
    private String remark;

    @ApiModelProperty(value = "控制状态", name = "openState")
    private String openState;

    @ApiModelProperty(value = "档案馆代码", name = "archivesCode")
    private String archivesCode;

    @ApiModelProperty(value = "归档时间", name = "archivingTime")
    private String archivingTime;

    @ApiModelProperty(value = "创建人", name = "createBy")
    private String createBy;

    @ApiModelProperty(value = "修改人", name = "updateBy")
    private String updateBy;

//	@ApiModelProperty(value = "过期时间", name = "expireTime")
//	private String expireTime;

    //DicDocState
    @ApiModelProperty(value = "0 整理 1归档审批 2归档 3 鉴定 4销毁  5回收站 6预归档(外部文件)", name = "state")
    private String state;

    @ApiModelProperty(value = "dossier 卷 doc 文件 scattered 散文件", name = "fileType")
    private String fileType;

    @ApiModelProperty(value = "办结开始时间", name = "startTime")
    private String startTime;

    @ApiModelProperty(value = "办结结束时间", name = "endTime")
    private String endTime;

    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @ApiModelProperty(value = "创建时间", name = "createTime", example = "2019-09-09 00:00:00")
    private LocalDateTime createTime;

    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @ApiModelProperty(value = "修改时间", name = "updateTime", example = "2019-09-09 00:00:00")
    private LocalDateTime updateTime;

    @ApiModelProperty(value = "部门Id", name = "deptId")
    private String deptId;

    @ApiModelProperty(value = "延长时间", name = "prolongTime")
    private Integer prolongTime;
    @ApiModelProperty(value = "文件来源", name = "docFrom")
    private String docFrom;
    @ApiModelProperty(value = "部门名称", name = "deptName")
    private String deptName;
    @ApiModelProperty(value = "系统归档时间", name = "sysArchivingTime")
    private String sysArchivingTime;


    @ApiModelProperty(value = "文号", name = "writingNum")
    private String writingNum;
    @ApiModelProperty(value = "类别", name = "category")
    private String category;
    @ApiModelProperty(value = "起止日期", name = "startEndDate")
    private String startEndDate;
    @ApiModelProperty(value = "项目代号", name = "projectCode")
    private String projectCode;
    @ApiModelProperty(value = "文字页数（凭证张数）", name = "textPages")
    private Integer textPages;
    @ApiModelProperty(value = "图纸张数（附件张数）", name = "drawingPages")
    private Integer drawingPages;
    @ApiModelProperty(value = "脊背宽度", name = "backWidth")
    private String backWidth;
    @ApiModelProperty(value = "存放位置", name = "depositLocation")
    private String depositLocation;


    @TableField(exist = false)
    @ApiModelProperty(value = "文件路径", name = "isFile")
    private String isFile;
    @TableField(exist = false)
    private String identType;
    @TableField(exist = false)
    private String identValue;

    private String ext01;
    private String ext02;
    private String ext03;
    private String ext04;
    private String ext05;
    private String ext06;
    private String ext07;
    private String ext08;
    private String ext09;
    private String ext10;
    private String ext11;
    private String ext12;
    private String ext13;
    private String ext14;
    private String ext15;
    private String ext16;
    private String ext17;
    private String ext18;
    private String ext19;
    private String ext20;
    @ApiModelProperty(value = "isDelete", name = "isDelete")
    private String isDelete;
    @TableField(exist = false)
    private String startYear;
    @TableField(exist = false)
    private String startMonth;
    @TableField(exist = false)
    private String startDay;
    @TableField(exist = false)
    private String endYear;
    @TableField(exist = false)
    private String endMonth;
    @TableField(exist = false)
    private String endDay;

    public void setDate() {
        try {
            LocalDate parseStart = LocalDate.parse(this.startTime, DateTimeFormatter.ofPattern("yyyyMMdd"));
            this.startYear = parseStart.getYear() + "";
            this.startMonth = (parseStart.getMonthValue() < 10) ? ("0" + parseStart.getMonthValue()) : (parseStart.getMonthValue() + "");
            this.startDay = parseStart.getDayOfMonth() < 10 ? ("0" + parseStart.getDayOfMonth()) : (parseStart.getDayOfMonth() + "");
        } catch (Exception e) {

        }
        try {
            LocalDate parseEnd = LocalDate.parse(this.endTime, DateTimeFormatter.ofPattern("yyyyMMdd"));
            this.endYear = parseEnd.getYear() + "";
            this.endMonth = (parseEnd.getMonthValue() < 10) ? ("0" + parseEnd.getMonthValue()) : (parseEnd.getMonthValue() + "");
            this.endDay = parseEnd.getDayOfMonth() < 10 ? ("0" + parseEnd.getDayOfMonth()) : (parseEnd.getDayOfMonth() + "");
        } catch (Exception e) {

        }
    }

    @ApiModelProperty(value = "文件列表", name = "files")
    @TableField(exist = false)
    private List<ArchivesDocFile> files;

    @ApiModelProperty(value = "扩展字段 key列名 value列值", name = "ext")
    @TableField(exist = false)
    private Map<String, Object> ext = new HashMap<>();

    @ApiModelProperty(value = "扩展字段 key列名 value列值", name = "ext")
    @TableField(exist = false)
    private List<Map<String, Object>> extList = new ArrayList<>();

    private String fileKeyword;


    @TableField(exist = false)
    @ApiModelProperty(value = "四性检测状态 true、false", name = "fourTest")
    private String fourTest;
    @TableField(exist = false)
    @ApiModelProperty(value = "四性检测结果", name = "fourTest")
    private String fourResult;

    @ApiModelProperty(value = "申请人", name = "applicant")
    private String applicant;
    @ApiModelProperty(value = "事项编码", name = "itemCode")
    private String itemCode;
    @ApiModelProperty(value = "事项名称", name = "itemName")
    private String itemName;
    @ApiModelProperty(value = "办件类型", name = "assort")
    private String assort;
    @ApiModelProperty(value = "受理部门", name = "orgCode")
    private String orgCode;
    @ApiModelProperty(value = "事项时限设置", name = "timeLimit")
    private String timeLimit;
    @ApiModelProperty(value = "办件编号", name = "receiveNumber")
    private String receiveNumber;
    @ApiModelProperty(value = "事项类型", name = "type")
    private String type;
    @ApiModelProperty(value = "外部接受文件办理人", name = "acceptUserName")
    private String acceptUserName;
    @ApiModelProperty(value = "外部接受文件来源", name = "source")
    private String source;

    @ApiModelProperty(value = "组卷/件人", name = "groupBy")
    private String groupBy;

    @ApiModelProperty(value = "组卷/件时间", name = "groupTime")
    private String groupTime;

    @ApiModelProperty(value = "归档包类型", name = "filingPageType")
    private String filingPageType;

    @ApiModelProperty(value = "文件总大小", name = "docTotalSize")
    private String docTotalSize;

    @TableField(exist = false)
    @ApiModelProperty(value = "扩展字段 归档包中doc名称", name = "docName")
    private String docName;

    @TableField(exist = false)
    @ApiModelProperty(value = "扩展字段 归档包中doc路径", name = "docPath")
    private String docPath;

    @TableField(exist = false)
    @ApiModelProperty(value = "质保资料，施工合同段id", name = "lmId")
    private String lmId;

    @TableField(exist = false)
    @ApiModelProperty(value = "挂接文件的页数", name = "mountPage")
    private Integer mountPage;

    @TableField(exist = false)
    @ApiModelProperty(value = "距离档案过期剩余的天数", name = "remainDay")
    private String remainDay;

    public static void initData(ArchivesDoc ad) {
        ad.setSecret("0");
    }

}
